package com.dubbo.lian.cms.modules.app.service.impl;
 import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dubbo.lian.cms.modules.app.Userdata;
import com.dubbo.lian.cms.modules.app.mapper.UserdataMapper;
import com.dubbo.lian.cms.modules.app.service.IUserdataService;
import com.dubbo.lian.common.util.BaseR;
import com.dubbo.lian.common.util.ReturnTemplateUtil;
import com.dubbo.lian.common.util.TimeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 import java.util.Date;
 /**
 * <p>
 *   服务实现类
 * </p>
 *
 * @author lian
 * @since 2016-12-22
 */
@Service
public class UserdataServiceImpl extends ServiceImpl<UserdataMapper, Userdata> implements IUserdataService {
     protected static Logger logger = LoggerFactory.getLogger(UserdataServiceImpl.class);
    @Autowired
    private UserdataMapper userdataMapper;
     @Override
    public BaseR selectUserLastData(JSONObject json) {
        try {
            Userdata userdata = new Userdata();
            EntityWrapper ew = new EntityWrapper();
            ew.setEntity(new Userdata());
            ew.where("isdel = {0}",0)
                    .andNew("userid = {0}",json.getString("userid"))
                    .orderBy("createtime");
            Date LastDate = userdata.selectOne(ew).getCreatetime();
            String str = TimeUtil.getTimeFormatText(LastDate);
            return ReturnTemplateUtil.returnOfString(str);
        } catch (Exception e) {
            return ReturnTemplateUtil.errReturn("没有称过",logger);
        }
    }
 }